﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Text;


namespace IHISCETeim.Web.MachineSys.PartsModel
{
    public partial class PartsCatheringAdd : PageBase
    {
        protected override string DWZRef
        {
            get
            {
                return "PartsCatheringList";
            }
        }

        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.新增 };
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "add")
            {
                addmenu();

            }
        }
        private void addmenu()
        {
            PartsCatheringInfo obj = Request.SerializableObject<PartsCatheringInfo>();
          
            obj.RealName = base.User.RealName;
            obj.State = "未冲完";
            obj.CardCode = GetRequestValue<string>("dwz.orgLookup.CardCode", "");
            obj.CardName = GetRequestValue<string>("dwz.orgLookup.CardName", "");

            if (string.IsNullOrEmpty(obj.KuanXiangLeiXing))
            {
                ErrorJson("请选择款项类型.");
                return;
            }
            int id = PartsCatheringController.Add(obj);
            if (id > 0)
            {
                //跳转参数
                string msg = "已成功收款,进入冲帐界面...";
                string tabTitle = "冲帐";
                string taburl = "PartsModel/PartsBalanceAdd.aspx?CId=" + id.ToString();
                string tabrelId = "PartsBalanceAdd";
                SuccessDialogOpenNavTab(msg, tabTitle, taburl, tabrelId);
                SuccessJson("新增成功");
            }
            else
            {

                ErrorJson("新增失败");
            }

        }
    }
}